<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/main.css" />
    <script type="text/javascript" src="../script/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/public.js"></script>
   <script type="text/javascript" src="../script/app.js"></script>
    <title>食堂付款</title>
</head>
<body>
<header>
    <div class="xiaomaib">
        <div>
            <img src="../image/jiant_rg.png" alt="" onclick="open_winrs('index','index.html')">
            <p>食堂付款</p>
        </div>
    </div>
</header>
<section>
    <div class="shit_fk">
        <p>选择付款金额</p>
        <ul id="jine">
            
        </ul>
    </div>
    <div class="fukuan">
        <p>付款金额</p>
        <span>
            <em>￥</em>
            <input name="balance" type="text" autofocus="autofocus">
        </span>
    </div>

    <div class="xmb_btn">
        <input type="button" value="确定" onclick="fukuan()">
    </div>
</section>
</body>
<script>
    $(function () {

        $(document).on("click",".shit_fk ul li input",function () {

            if ($(this).hasClass("chkde_ths")){

                return;
            }else {

                $(".shit_fk ul li input").removeClass("chkde_ths");
                $(this).parents(".selct_dom").prev(".clec_kes1").attr("data-id",$(this).attr('data-id'));
                $(this).addClass("chkde_ths");
            }
        })
    })
</script>
<script type="text/javascript">
    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();

    var num = '';
    apiready = function () {
        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });

        

        //付款金额
        api.ajax({
            url:webSiteUrl+'/app/record/price',
            method:'post',
            data:{
               
            }
        },function(ret ,err){

            // alert(JSON.stringify(err));

            api.hideProgress();

            if (ret.code == 200) {
                var je = ret.data;
                html = '';
                for (var i=0 ; i<je.length ; i++) {
                   html += '<li onclick="jin('+je[i].id+')"><input name="sum" type="button" value="'+je[i].price+'元"></li>';
                }
                $('#jine').html(html);
            }else{
                alert(ret.msg);
            }
        });

    }
    

    function jin(id){
        num = id;
    }
    

    //付款
    function fukuan(){
        var did = api.deviceId;
        var balance = $('input[name=balance]').val();
       
        var p = {uid:id,price_id:num,balance:balance,did:did};

        api.ajax({
            url:webSiteUrl+'/App/record/mess',
            method:'post',
            data:{
                values: p
            }
        },function(ret,err){
           // alert(JSON.stringify(err));
            if(ret.code == 200){
                api.openWin({
                    name: 'zhifu',
                    url: './zhifu_cg.html',
                    reload:true,
                    pageParam: {
                        balance: ret.data.balance,
                        total:ret.data.total
                    }
                });
            }else{
                alert(ret.msg)
            }
        });
    }

    
</script>
</html>